//
//  HLGiftListRequest.m
//  YueYue
//
//  Created by hulu001 on 2023/6/3.
//

#import "HLGiftListRequest.h"

@implementation HLGiftListRequest
{
    NSDictionary *_params;
    HLGiftListType _type;
}

- (id)initWithType:(HLGiftListType)type params:(NSDictionary *)params
{
    self = [super init];
    
    if (self) {
        _type = type;
        _params = params;
    }
    
    return self;
}



- (NSString *)requestUrl
{
    switch (_type) {
        case HLGiftListTypeList:
            return @"/consume/giftList";
            break;
        case HLGiftListTypeBag:
            return @"/active/gift/list";
            break;
    }
    
}

- (YTKRequestMethod)requestMethod
{
    return YTKRequestMethodGET;
}

- (id)requestArgument
{
    if (_params){
        return _params;
    } else {
        return @{};
    }
}

- (NSArray <HLGiftModel *> *)giftList
{
    NSArray *lists = @[];
    
    NSArray *records = [self.result valueForKey:@"data"];
    if (records.count > 0) {
       lists = [HLGiftModel mj_objectArrayWithKeyValuesArray:records];
    }
    
    for (HLGiftModel *gift in lists) {
        gift.giftListType = _type;
    }
    
    return lists;
}


@end
